﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Http;
using Jw.Core;
using Jw.Models;

namespace Jw.Web.Areas.Mms.Controllers
{

    public class PacmController : Controller
    {
        //
        // GET: /Mms/Pacm/
        public ActionResult Index(int id)
        {

            ViewBag.Mc = "xiaoping";
            return View();
        }

        public ActionResult List(string id)
        {
            var model = new
            {
                urls = new
                {
                    query = "/api/mms/pacm"
                },
                resx = new
                {
                    noneSelect = "请先选择一条产品数据！",
                    editSuccess = "保存成功！",
                    auditSuccess = "单据已审核！"
                },
                form = new
                {
                    Aname = "",
                },
            };

            return View(model);
        }
    }

    public class PacmApiController : ApiController
    {
        public dynamic Get(RequestWrapper query)
        {

            query.LoadSettingXmlString(@"
<settings defaultOrderBy='Aname'>
    <select>
        *
    </select>
    <from>
        Tpacm
    </from>
    <where defaultForAll='true' defaultCp='equal' defaultIgnoreEmpty='true' >
        <field name='Aname'             cp='equal'      ></field>
    </where>
</settings>
");
            var pQuery = query.ToParamQuery();
            var list = new TpacmService().GetDynamicListWithPaging(pQuery);
            return list;
        }

    }

}
